<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Language" content="en">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google" content="notranslate" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>adminMongo</title>
    <link rel='stylesheet' type='text/css' href='{{app_context}}/bootstrap/css/bootstrap.min.css' />
    <link rel='stylesheet' type='text/css' href='{{app_context}}/css/flatly.bootstrap.min.css' />
    <link rel="stylesheet" type='text/css' href='{{app_context}}/css/highlightjs.github.min.css'>
    <link rel='stylesheet' type='text/css' href='{{app_context}}/css/style.css' />
    <link rel='stylesheet' type='text/css' href='{{app_context}}/font-awesome/css/font-awesome.min.css' />
    <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
    <script src="{{app_context}}/jquery/jquery.min.js"></script>
    <script src="{{app_context}}/bootstrap/js/bootstrap.min.js"></script>
    {{#if paginate}}
    <script src="{{app_context}}/js/jquery.bootpag.min.js"></script>
    {{/if}}
    {{#if editor}}
    <script src="{{app_context}}/js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="{{app_context}}/js/toEJSON.js"></script>
    <script src="{{app_context}}/js/editor.js"></script>
    {{/if}}
    {{#if monitoring}}
    <script src="{{app_context}}/js/moment.min.js"></script>
    <script src="{{app_context}}/js/chart.min.js"></script>
    <script src="{{app_context}}/js/servermonitoring.js"></script>
    {{/if}}
    <script src="{{app_context}}/js/adminMongo.js"></script>
    <script src="{{app_context}}/js/highlight.min.js"></script>
    <script>if (window.module) module = window.module;</script>
</head>
<body>
    <div class="container-fluid wrapper">
        <div class="row row-offcanvas row-offcanvas-left">
            {{#if sidebar_list}}
            <div id="sidebar" class="column no-side-pad hidden-xs col-xs-12 col-sm-3 col-lg-2 sidebar-offcanvas">
                <div class="row">
                    <div class="col-lg-12 no-pad-left no-pad-right">
                        <div class="navTitle"> 
                            <a href="{{app_context}}/app"><img src="{{app_context}}/static/logo.png">adminMongo</a>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12 no-pad-left no-pad-right">
                        <ul class="list-group">
                            <li class="list-group-item list-group-item-primary">{{__ "Database Objects"}}</li>
                            {{#if conn_name}}
                                <li class="list-group-item"><i class="fa fa-plug"></i>&nbsp;<a href="{{app_context}}/app/{{conn_name}}">{{conn_name}}</a></li>
                            {{/if}}
                            {{#each sidebar_list}}
                                <li class="list-group-item mainMenu"><i class="fa fa-database"></i>&nbsp; <a href="{{app_context}}/app/{{@root.conn_name}}/{{@key}}">{{@key}}</a><div class="pull-right mainMenuToggle"><i class="fa fa-angle-down" aria-hidden="true"></i></div></li>
                                {{#each this}}
                                    <li class="list-group-item coll_indent sub-menu">&nbsp;&nbsp;&nbsp;<i class="fa fa-table"></i>&nbsp;&nbsp;&nbsp;<a href="{{app_context}}/app/{{@root.conn_name}}/{{@../key}}/{{this}}/view">{{this}}</a></li>
                                {{/each}}
                            {{/each}}
                        </ul>
                        <ul class="list-group">
                            <li class="list-group-item list-group-item-primary">{{__ "Connections"}}</li>
                            {{#each conn_list}}
                                <li class="list-group-item"><i class="fa fa-plug"></i>&nbsp;<a href="{{app_context}}/app/{{@key}}">{{@key}}</a></li>
                            {{/each}}
                        </ul>
                    </div>
                </div>
            </div>
            {{/if}}
            {{#ifOr monitoring connection_list}}
            <div class="col-md-12 col-lg-12" id="main">
            {{else}}
            <div class="column col-xs-12 col-sm-9 col-lg-10" id="main">
            {{/ifOr}}
                <nav class="navbar navbar-default navbar-static-top">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <div class="container-fluid no-pad-left">
                        {{#ifOr monitoring connection_list}}
                            <div class="navbar-left no-pad-left no-pad-right">
                                <div class="navTitle navTitleDark"> 
                                    <a href="{{app_context}}/app"><img src="{{app_context}}/static/logo.png">adminMongo</a>
                                </div>
                            </div>
                        {{/ifOr}}
                        {{#ifNotOr monitoring connection_list}}
                            <div class="navbar-left no-pad-left no-pad-right">
                                <button type="button" id="sidebarToggle" class="btn btn-success btn-sm pull-left"><i class="fa fa-bars" aria-hidden="true"></i></button>
                            </div>
                        {{/ifNotOr}}
                        <ul class="nav navbar-nav navbar-right">
                            <div id="navbar" class="navbar-collapse collapse">
                                <ul class="nav navbar-nav">
                                    {{#if conn_name}}
                                        <li><a href="{{app_context}}/app/monitoring/{{conn_name}}"><i class="fa fa-desktop"></i>&nbsp; {{__ "Monitoring"}}</a></li>
                                    {{/if}}
                                    <li><a href="{{app_context}}/app/connection_list"><i class="fa fa-plug"></i>&nbsp; {{__ "Connections"}}</a></li>
                                    {{#if session.loggedIn}}
                                        <li><a href="{{app_context}}/app/logout"><i class="fa fa-sign-out"></i>&nbsp; {{__ "Logout"}}</a></li>
                                    {{/if}}
                                </ul>
                            </div
                        </ul>
                    </div>
                </nav>
                {{#unless monitoring}}
                    {{#if conn_name}}
                        <div class="row">
                            <div class="col-lg-12">
                                <h3 class="text-center banner-heading">
                                    {{__ "Database"}}:
                                    {{#if db_name}}
                                        <a href="{{app_context}}/app/{{conn_name}}/{{db_name}}">{{db_name}}</a>
                                    {{else}}
                                        <span class="text-warning"><i>{{__ "Not selected"}}</i></span>
                                    {{/if}}
                                    / {{__ "Collection"}} -
                                    {{#if coll_name}}
                                        <span id="headCollectionName" class="text-info">{{coll_name}}</span>
                                        <button type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#collectioName">
                                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                        </button>
                                    {{else}}
                                        <span class="text-warning"><i>{{__ "Not selected"}}</i></span>
                                    {{/if}}
                                </h3>
                            </div>
                        </div>
                    {{/if}}
                {{/unless}}
                {{{body}}}
            </div>
            <input type="hidden" value="{{coll_count}}" id="coll_count">
            <input type="hidden" value="{{conn_name}}" id="conn_name">
            <input type="hidden" value="{{db_name}}" id="db_name">
            <input type="hidden" value="{{coll_name}}" id="coll_name">
            <input type="hidden" value="{{docs_per_page}}" id="docs_per_page">
            <input type="hidden" value="{{paginate}}" id="to_paginate">
            <input type="hidden" value="{{app_context}}" id="app_context">
            <input type="hidden" value="{{doc_id}}" id="doc_id">
            <input type="hidden" id="export_coll"> 
            <div id="mobile-indicator"></div>                  
        </div>
        <!-- Collection Name Modal -->
        <div class="modal fade" id="collectioName" tabindex="-1" role="dialog" aria-labelledby="collectionNameLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="collectionNameLabel">{{__ "Edit Collection name"}}</h4>
                </div>
                <div class="modal-body">
                    <input type="text" class="form-control" id="coll_name_newval" value="{{coll_name}}">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">{{__ "Close"}}</button>
                    <button type="button" class="btn btn-success btn-sm" id="coll_name_edit">{{__ "Save changes"}}</button>
                </div>
                </div>
            </div>
        </div>
        <!-- Collection Name Modal -->
        <!-- Search documents Modal -->
        <div class="modal fade" id="searchModal" tabindex="-1" role="dialog" aria-labelledby="documentSearchLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="collectionNameLabel">{{__ "Search for documents"}}</h4>
                    <p>{{__ "BSON types are not supported"}}</p>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="recipient-name" class="control-label">{{__ "Key (Field)"}}:</label>
                        <select class="form-control" id="search_key_fields"></select>
                    </div>
                    <div class="form-group">
                        <label for="message-text" class="control-label">{{__ "Value"}}</label>
                        <input type="text" class="form-control" id="search_value_value" placeholder="{{__ "Value"}}">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-sm pull-left" data-dismiss="modal">{{__ "Close"}}</button>
                    <button type="button" class="btn btn-success btn-sm pull-right" id="searchModalAction">{{__ "Search"}}</button>
                </div>
                </div>
            </div>
        </div>
        <!-- Search documents Modal -->
        <!-- Query Modal -->
        <div class="modal fade" id="queryDocuments" tabindex="-1" role="dialog" aria-labelledby="queryDocumentsLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="collectionNameLabel">{{__ "Query documents"}}</h4>
                        <p>{{__ "Queries need to be BSON types or Extended JSON formatted"}}</p>
                    </div>
                    <div class="modal-body">
                        <div class="edit_json" id="json">{}</div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default btn-sm pull-left" data-dismiss="modal">{{__ "Close"}}</button>
                        <button type="button" class="btn btn-success btn-sm pull-right" id="queryDocumentsAction">{{__ "Send query"}}</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- Query Modal -->
        <!-- Export collection Modal -->
        <div class="modal fade" id="exportModal" tabindex="-1" role="dialog" aria-labelledby="exportCollectionLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="collectionNameLabel">{{__ "Export collection"}}</h4>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="checkbox">
                            <label>
                                <input id="exportExcludeID" type="checkbox"> {{__ "Exclude"}} "_id" {{__ "field"}}?
                            </label>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-sm pull-left" data-dismiss="modal">{{__ "Close"}}</button>
                    <button type="button" class="btn btn-success btn-sm pull-right" id="exportModalAction">{{__ "Export"}}</button>
                </div>
                </div>
            </div>
        </div>
        <!-- Export collection Modal -->
    </div>
    <div id="notify_message"></div>
  </body>
</html>
